package com.campus.service.impl;

import com.campus.dao.CourseDao;
import com.campus.dto.CourseConditionDto;
import com.campus.model.Course;
import com.campus.service.CourseService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@Slf4j
public class CourseServiceImpl implements CourseService {

    @Autowired
    private CourseDao courseDao;

    @Override
    public boolean createCourse(Course course) {
        return courseDao.createCourse(course) > 0;
    }

    @Override
    public List<Course> getCoursesByCondition(CourseConditionDto condition) {
        return courseDao.getCoursesByCondition(condition);
    }

    @Override
    public boolean deleteCourse(int courseId) {
        return courseDao.deleteCourse(courseId) > 0;
    }

    @Override
    public boolean updateCourse(Course course) {
        return courseDao.updateCourse(course) > 0;
    }

    @Override
    public List<Course> getAllCourses() {
        return courseDao.findAllCourses(); // 调用 Dao 层方法
    }

}
